<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .box1 {
        width: 300px;
        height: 300px;
        background-color: skyblue;
      }
      /* .box1::before {
        content: '';
        display: inline-block;
        display: block;
        display: table;
      } */
      .box2 {
        width: 200px;
        height: 200px;
        background-color: springgreen;
        margin-top: 100px;
      }
      .clearfix::before,
      .clearfix::after {
        content: '';
        display: table;
        clear: both; /* .clearfix::before:{content: '';display: table;}  解决外边距重叠*/
        /* .clearfix::after: {content: '';clear: both;}   清楚浮动影像*/
      }
    </style>
  </head>
  <body>
    <div class="box1 clearfix">
      <div class="box2"></div>
    </div>
  </body>
</html>
